package com.fesine.ch01.lesson07.t13;

/**
 * Created by Fesine on 2016/6/27.
 */
public class MyThread extends Thread {
    @Override
    public void run() {
        super.run();
        try {
            for (int i = 0; i < 500000; i++) {

                if (this.interrupted()) {
                    System.out.println("已经是停止状态了！我要退出了！");
                    throw new InterruptedException();
                }
                System.out.println("i = " + (i + 1));
            }
            System.out.println("我在for下面");
        } catch (InterruptedException e) {
            System.out.println("进入MyThread.java类run方法中的catch了");
            e.printStackTrace();
        }
        System.out.println("我被输出，如果此代码是for又继续运行，线程并未停止！");
    }
}
